package com.jt.controller;

import com.jt.pojo.Rights;
import com.jt.service.RightsService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/rights")
@RestController
@CrossOrigin
public class RightsController {

    @Autowired
    private RightsService rightsService;


//    @GetMapping("getRightsList")
//    public List<Rights> getRightSList()
//    {
//        return rightsService.findAll();
//    }


    @GetMapping("/getRightsList")
    public SysResult getRightsList()
    {
        List<Rights> rightsList=rightsService.getRightsList();
        return  SysResult.success(rightsList);

    }

    @GetMapping("/getRightsListAll")
    public SysResult getRightsListAll()
    {
        List<Rights> rightsList=rightsService.getRightsListAll();
        return  SysResult.success(rightsList);

    }

    @PutMapping("/updateRights")
    public SysResult updateRights(@RequestBody Rights rights)
    {
            rightsService.updateRights(rights);
           return  SysResult.success();
    }

    @GetMapping("/getThreeRightsIds")
    public  SysResult getThreeRightsIds(Integer roleId)
    {
        List<Integer> threeRightsIds=rightsService.getThreeRightsIds(roleId);
        return SysResult.success(threeRightsIds);
    }
}
